// 登录验证
export const accountCheck = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入账号"));
  } else if (!/^[A-Za-z0-9\u4e00-\u9fa5]{3,6}$/.test(value)) {
    return callback(new Error("长度在3~6之间，包含字母、数字和中文"));
  } else {
    callback();
  }
};
//   密码验证
export const pwdcheck = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入密码"));
  } else if (!/^[A-Za-z0-9]\w{4,12}$/.test(value)) {
    return callback(
      new Error("以字母开头，长度在6~18之间，只能包含字母、数字和下划线")
    );
  } else {
    callback();
  }
};
// 身份证验证
export const IDUnber = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入身份证"));
  } else if (!/^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/.test(value)) {
    return callback(
      new Error("请输入正确身份证号")
    );
  } else {
    callback();
  }
};
// 电话
export const cellPhone = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入手机号"));
  } else if (!/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/.test(value)) {
    return callback(
      new Error("请输入正确手机号")
    );
  } else {
    callback();
  }
};
// 验证非空
export const userNames = (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入名字"));
  } else {
    callback();
  }
};
// 验证账号
export const accountNames =  (rule, value, callback) => {
  if (!value) {
    return callback(new Error("请输入账号"));
  } else if (!/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/.test(value)||!/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(value)) {
    return callback(
      new Error("请输入正确账号")
    );
  } else {
    callback();
  }
};